export const useType = () => {
  /**
   * @description 类型判断
   * @param {*} value 需要判断的值 {*}checkType 判断的类型
   * @returns Boolean
   */
  const isType = (value, checkType) => {
    return Object.prototype.toString.call(value) === `[object ${checkType}]`;
  };

  /**
   * @description 判断两个对象是否全等
   * @param {Object} a
   * @param {Object} b
   * @returns Boolean
   */
  const isObjectValueEqual = (a, b) => {
    var aProps = Object.getOwnPropertyNames(a);
    var bProps = Object.getOwnPropertyNames(b);
    if (aProps.length != bProps.length) {
      return false;
    }
    for (var i = 0; i < aProps.length; i++) {
      var propName = aProps[i];

      var propA = a[propName];
      var propB = b[propName];
      // 先判断两边都有相同键名
      if (!b.hasOwnProperty(propName)) return false;
      if (propA instanceof Object) {
        if (this.isObjectValueEqual(propA, propB)) {
        } else {
          return false;
        }
      } else if (propA !== propB) {
        return false;
      } else {
      }
    }
    return true;
  };

  return {
    isType,
    isObjectValueEqual,
  };
};
